Add Sentry error monitoring (backend, frontend, SSR)#16
Merged
Conversation
Errors-only Sentry integration, opt-in via env vars — inert without a DSN, so dev/test/local report nothing. - Backend: sentry + hackney deps, Sentry.PlugCapture/PlugContext, and the Sentry.LoggerHandler (captures Bandit request crashes + Oban job failures). ElixirReactStarter.Sentry enforces the no-PII rule via before_send and a PlugContext body scrubber (unit-tested). - Frontend: @sentry/react, init from a nonce-safe meta tag (works under the strict CSP); ErrorBoundary reports caught render errors. - SSR: @sentry/node in the Inertia SSR workers, reporting render failures before re-raising so Inertia's fallback is unchanged. - Source maps: external maps in assets.deploy, uploaded via @sentry/cli (build/upload-sourcemaps.js, best-effort) then deleted before phx.digest; backend source context packaged in the Dockerfile. - SENTRY_RELEASE defaults to RENDER_GIT_COMMIT; environment from DEPLOY_ENV. Also document two TS style conventions in CLAUDE.md (extract multi-line go()/goSync() callbacks; multi-line bodies use braces + return) and apply them across assets/js, and exclude the routes.gen mix task from coverage (pure tooling, exercised by precommit) like the other custom tasks.
unmatched_return: Logger.add_handlers/1 returns :ok | {:error, _}. The
:logger handler config is static (config/config.exs) so it always returns
:ok; match it explicitly to document that and fail loudly on a genuine
misconfig.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Errors-only Sentry integration, opt-in via env vars — inert without a DSN, so dev/test/local report nothing.
Backend
sentry+hackneydeps;Sentry.PlugCapture(aboveuse Phoenix.Endpoint) andSentry.PlugContext(afterPlug.Parsers).Sentry.LoggerHandlerattached at boot — captures Bandit request crashes and Oban job failures.ElixirReactStarter.Sentryenforces the no-PII rule:before_sendstrips the user's email (keeps the id for correlation), and aPlugContextbody scrubber drops email/token/code/password params. Unit-tested.Frontend
@sentry/react, initialised from nonce-safe<head>meta tags (works under the strict CSP), surfaced viaSharedData→root.html.heex.ErrorBoundaryreports caught render errors.SSR
@sentry/nodein the Inertia SSR Node workers;renderis now async and routes failures throughgo(), reporting before re-raising so Inertia's own fallback is unchanged.Source maps
assets.deploy, uploaded best-effort via@sentry/cli(build/upload-sourcemaps.js), then deleted beforephx.digestso they're never served.Dockerfile(mix sentry.package_source_code).Config
SENTRY_DSN, frontendSENTRY_DSN_FRONTEND, SSRSENTRY_DSN_SSR(falls back to the frontend DSN).DEPLOY_ENV(distinct fromMIX_ENV); release defaults toRENDER_GIT_COMMIT, overridable viaSENTRY_RELEASE.Also
CLAUDE.md(extract multi-linego()/goSync()callbacks; multi-line bodies use braces +return) and applied them acrossassets/js.routes.genmix task from coverage (pure tooling, exercised by precommit), like the other custom tasks. Coverage: 92.71% total, above the 90% threshold.Verified:
mix precommitgreen (credo, biome, i18n, route drift, 204 tests), both asset bundles build.🤖 Generated with Claude Code